/*
*================================================================================
*	Plik: f_ld8.c
*	Created on: Jun 4, 2011
*--------------------------------------------------------------------------------
*	Autorzy: Piotr Zdunek, Mateusz Słowikowski, Krzysztof Wiąckowski
*	Projekt: Model mikrokontrolera AVR
*	Kompilator: avr-gcc-4.3.5
*	Doc: doxygen 1.4.3
*--------------------------------------------------------------------------------
*	Zawiera: 
*--------------------------------------------------------------------------------
*	Komentarze:
*================================================================================
*/

#include "types.h"
#include "mem_abs.h"

void F_LDDZ() {

#ifndef DEBUG_MODE
	printf("Function LDDZ.");
#endif


	uint8_t k = 0;
	k = ((getMEMC(getPC()) & 0x000F) & 0b0111);
	k = k | ((((getMEMC(getPC()) & 0x0F00)) >> 8) & 0b1100) << 1;
	k = k | (((getMEMC(getPC()) & 0xF000) >> 12) & 0b0010) << 4;

	displaceZ(k);

	//Resolve variable value form opcode
	uint8_t Rd = (((getMEMC(getPC()) & 0x0FF0) & 0b00011111)) >> 4;
	uint8_t Rd_val = GetRegisterFromDataSpace(GetZRegister());


	setRegister(Rd, Rd_val);
	incPC();

}

